﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectNode.aspx.cs" Inherits="Honestysoft.Workflow.Client.WebUI.Workflow.WFDesigner.SelectNode" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns:v="urn:schemas-microsoft-com:vml" >
<head runat="server">
     <base target="_self" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>   
<script language="javascript" type="text/javascript"  src="<%=Page.ResolveClientUrl("~/") %>Workflow/WFDesigner/js/NodeSelect/webflow.js"></script>
<script language="javascript" type="text/javascript"  src="<%=Page.ResolveClientUrl("~/") %>Workflow/WFDesigner/js/NodeSelect/movestep.js"></script>
<script language="javascript" type="text/javascript" src="<%=Page.ResolveClientUrl("~/") %>Workflow/Scripts/jquery-1.4.1.js"></script>
<script language="javascript" type="text/javascript" src="<%=Page.ResolveClientUrl("~/") %>Workflow/Scripts/jquery.easyui.min.js"></script>
<style type="text/css">
v\:* { Behavior: url(#default#VML) }
</style>  
 <style type="text/css">
        body
        {
            font-size:12px;
        }
        </style>
        <link href="../Styles/control.css" rel="stylesheet" type="text/css" />
</head>

<body style="margin:8px;" onload="loadFlow();"; oncontextmenu="return false;">
        <table width="96%" cellpadding="0" cellspacing="0">
            <tr height="500px" valign="top" align="left">
                <td style="width: 100%" valign="top">
                   <table border=0 style="width:100%;height:100%">
    <tr>	
        <td width="100%" height="100%" valign="top">
        <div style="border:1px solid #BABABA;height:500px">
                    <div style="height:500px;overflow:scroll">
            <table cellspacing="0" cellpadding="0" border="0">
                <tr>
                    <td  width="800" height="500" valign="top" onclick="return false;" oncontextmenu='return false;' valign=top align=left>
                        <v:group ID="FlowVML"  style="width:100%;height:100%;position:absolute;" coordsize="2500,2500">
                        </v:group>
                    </td>
                </tr>			
            </table>
            <input type="hidden" name="FlowXML" onpropertychange='if(AUTODRAW){ redrawVML();}' />
            </div>
            </div>
        </td>
    </tr>
</table>
                </td>
                <td>
                <div style="border:1px solid #BABABA;height:500px">
                    <table width="140px" class="t1" id="tSelectedNode">
                       <thead>
                        <th>节点名称</th>
                        <th style="width:40px">操作</th>
                       </thead>
                    </table>
                    </div>
                </td>
            </tr>            
        </table>
        <div style="text-align:right">
              <input type="button"  id="btnNext"   class="btn_normal" onmouseover="this.className='btn_active'" onmouseout="this.className='btn_normal'"  value="确  定" onclick="DoNext();" class="btn_normal" onmouseover="this.className='btn_active'" onmouseout="this.className='btn_normal'" />
                                <input type="button"  id="btnCancel" class="btn_normal" onmouseover="this.className='btn_active'" onmouseout="this.className='btn_normal'"  value="取  消"  onclick="window.close();" class="btn_normal" onmouseover="this.className='btn_active'" onmouseout="this.className='btn_normal'" />
                                &nbsp;&nbsp;&nbsp;&nbsp;
        </div>
   <input type="hidden" id="HidSelectNodeID" runat="server" />
   <script language="javascript" type="text/javascript">
       function nodeData() {
           var ID;
           var Name;
       }
       function IsSelected(id) {
           var arrSelected = GetSelected();
           if (arrSelected != null) {
               for (var i = 0; i < arrSelected.length; i++) {
                   if (arrSelected[i].ID == id.substring(10) || arrSelected[i].ID==id) {
                       return true;
                   }
               }
           }
           return false;
       }
       function GetSelected() {
           var tab = document.getElementById('tSelectedNode');
           if (tab.rows.length <= 1) {
               return null;
           }
           var arrSelected = new Array(tab.rows.length - 1);
           var item = null;
           for (var i = 1; i < tab.rows.length; i++) {//去掉表头行
               item = new nodeData();
               item.ID = tab.rows[i].cells[0].innerHTML;
               item.Name = tab.rows[i].cells[1].innerHTML;
               arrSelected[i - 1] = item;
           }
           return arrSelected;
       }
       function addRow(id,text) {
           if (IsSelected(id)) {
               return;
           }
           if ('<%=Request["mode"]+"" %>' == '1') {
               var arrSelected = GetSelected();
               if (arrSelected != null && arrSelected.length == 1) {
                   alert("只能选择一个节点！");
                   return;
               }
           }
           var str = "<tr id = 'tr" + id + "'><td style='display:none'>" + id + "</td><td>" + text + "</td><td><a href='javascript:void(0)' onclick=\"delRow('" + id + "');\">删除</a></td></tr>";
           $('#tSelectedNode').append(str);
       }
       function delRow(id) {
           $('#tr' + id).remove();
       }
       function loadFlow() {
           var data = window.dialogArguments;
           if (data != null) {
               if (data.length > 0) {
                   for (var i = 0; i < data.length; i++) {
                       addRow(data[i].ID,data[i].Name);
                   }
               }
           }
           FlowID = '<%=Request["FlowID"] %>';
           $.ajax({
               type: "POST",
               url: "JSON/Flow.ashx",
               data: "ActionType=0&FlowID=" + FlowID,
               success: function (msg) {
                   FlowXML.value = msg;
               }
           });
       }
       function DoNext() {
//           if (SelectNodeID == "") {
//               alert("请选择特送的目标活动环节！只能是人工活动环节！");
//               return;
           //           }
           var retValue = GetSelected();
           if (retValue == null) {
               retValue = new Array(0);
           }
           window.returnValue = retValue;
           window.close();
       }
    </script> 
</body>
</html>
